﻿<%@ WebHandler Language="C#" Class="lists" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Collections;



public class lists : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        // paramJson: {"onlyId":2313,"memberId":21,"pageNo":1,"pageSize":99}
          Uri uri = HttpContext.Current.Request.Url;
        String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port;

        var xxx=HttpContext.Current.Request.Form["paramJson"];
        JObject jo = (JObject)JsonConvert.DeserializeObject(xxx);



        string tid = jo["tid"].ToString();
        string id = "1";

        if (string.IsNullOrEmpty(id))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }

        var code = 1;
        var msg = "获取成功";
        var time = DateTime.Now;


        using (Entities bll = new Entities())
        {
            int _id = int.Parse(tid);

           

            var x = bll.P_Task.SingleOrDefault(xx=>xx.TID==_id);//全部.ToList();
            var imgs = methods.GetImgs(x.TImg);
            var data = new
            {
                Sname= x.TName,
                id = x.TID,
                intro = x.Tintroduce,
                text=x.TContent.Replace("src=\"/upload/","src=\""+host+"/upload/"),
                img = imgs,
                x.Tlatitude,
                x.Tlongitude,
                x.Taddress,

            };



            //全部.ToList();
            context.Response.Write(JsonConvert.SerializeObject(new { code, msg, time, data }));

        }

        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }




}